package com.freight.base.controller;

import com.freight.base.entity.Province;
import com.freight.base.service.ProvinceService;
import com.freight.core.base.FreightBaseController;
import com.freight.core.common.annotation.SecretAnnotation;
import com.freight.core.common.utils.PageUtil;
import com.freight.core.common.utils.ResultUtil;
import com.freight.core.common.vo.PageVo;
import com.freight.core.common.vo.Result;
import com.freight.core.common.vo.SearchVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author huyingtai
 */
@Slf4j
@RestController
@Api(description = "省份维表管理接口")
@RequestMapping("/freight/province")
@Transactional
public class BaseProvinceController extends FreightBaseController<Province, Long> {

    @Autowired
    private ProvinceService provinceService;

    @Override
    public ProvinceService getService() {
        return provinceService;
    }


    @RequestMapping(value = "/getByCondition", method = RequestMethod.GET)
    @ApiOperation(value = "多条件分页获取")
    @SecretAnnotation(decode=true,encode=true)
    public Result<Page<Province>> getByCondition(Province province, SearchVo searchVo, PageVo pageVo) {

        Page<Province> page = provinceService.findByCondition(province, searchVo, PageUtil.initPage(pageVo));
        return new ResultUtil<Page<Province>>().setData(page);
    }

}
